package com.anolesoft.webService.impl;

import com.anolesoft.webService.inf.ErpWebService;
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.xml.ws.Endpoint;

@Configuration//注册到spring启动中
public class CxfConfig {
    @Autowired
    private Bus bus;
    @Autowired
    private ErpWebService erpWebService;

    @Bean
    public ServletRegistrationBean servletRegistrationBean() {
        return new ServletRegistrationBean(
                new CXFServlet(), "/services/*");
    }

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(bus, erpWebService);
        endpoint.publish("/erpWebService");
        return endpoint;
    }

    @Bean
    public Endpoint endpointErp() {
        EndpointImpl endpoint = new EndpointImpl(bus, erpWebService);
        endpoint.publish("/erpWebServices");
        return endpoint;
    }
}
